import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import animated from 'animate.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
import './assets/css/global.css'
import 'bootstrap'
// import $ from 'jquery'
import qs from 'qs'
import validation from 'jquery-validation'
import axios from 'axios'
import less from 'less'
import TreeTable from 'vue-table-with-tree-grid'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 配置请求根路径
axios.defaults.baseURL = 'http://localhost:8088/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
axios.defaults.withCredentials = true
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.component('tree-table', TreeTable)
Vue.filter('dateFormat', function(origin) {
  const dt = new Date(origin)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
// 将富文本编辑器注册为全局可用的组件
Vue.use(VueQuillEditor)
Vue.use(less)
Vue.use(qs)
Vue.use(animated)
// axios.interceptors.response.use(function(res) {
//   console.log("success");
// }, function(err) {
//   console.log(err); // 打印错误日志
//   if (err.response && err.response.status == 401) {
//       router.replace({
//           path: '/login',
//           query: {
//               redirect: to.fullPath
//           } // 将跳转的路由path作为参数，登录成功后跳转到该路由
//       });
//   } else if (err.response && err.response.status) {
//       return Promise.reject(err.response && err.response.data); // 返回接口返回的错误信息
//   }
// });
// Vue.use(validation)
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
